package com.linwen.javase.desgin_pattern.BigTalkDesignPattenJAVACode._16迭代器模式._1迭代;

public class Test {

    public static void main(String[] args){


        ConcreteAggregate bus = new ConcreteAggregate();
        bus.add("大鸟");
        bus.add("小菜");
        bus.add("行李");
        bus.add("老外");
        bus.add("公交内部员工");
        bus.add("小偷");

        //正序迭代器
        Iterator conductor = new ConcreteIterator(bus);
        //倒序迭代器
        Iterator conductor2 = new ConcreteIteratorDesc(bus);
        System.out.println("倒序迭代");
        conductor.first();
        while (!conductor.isDone()) {
            System.out.println(conductor.currentItem() + "，请买车票!");
            conductor.next();
        }

        conductor2.first();
        while (!conductor2.isDone()) {
            System.out.println(conductor2.currentItem() + "，请买车票!");
            conductor2.next();
        }


    }
}





